#ifndef QIT_VIEW_CDEVICESETTINGSWIDGET_H_
#define QIT_VIEW_CDEVICESETTINGSWIDGET_H_

#include <QWidget>

#include "core/defines.h"
#include "ui_CDeviceSettingsWidget.h"

class CDeviceSettingsWidget : public QWidget
{
    Q_OBJECT
public:
    CDeviceSettingsWidget(QWidget *parent = nullptr);
    ~CDeviceSettingsWidget();

    void Reset();

protected:
    void init_view();
    void reset_view();
    QString generater_device_id();
    bool check_user_input();
    void set_zlbase_device(const ZLBaseDevice &device);
    void get_zlbase_device(ZLBaseDevice &device);
    void set_peripherals_device(const ZLPeripheralsDevice &device);
    void get_peripherals_device(ZLPeripheralsDevice &device);

signals:
    void deviceConfigChanged();

protected slots:
    void on_btn_close_clicked();
    void on_btn_add_clicked();
    void on_btn_modify_clicked();
    void on_btn_delete_clicked();
    void on_btn_save_clicked();

    void on_combo_device_type_currentIndexChanged(int index);
    void on_combo_protocol_type_currentIndexChanged(int index);
    void on_combo_protocol_name_currentIndexChanged(int index);
    void on_combo_datalink_type_currentIndexChanged(int index);

    void eventDeviceChanged(QString id);

private:
    Ui::CDeviceSettingsWidget ui;
    ZLDeviceConfig device_config_;
};

#endif  // QIT_VIEW_CDEVICESETTINGSWIDGET_H_